#include "update_session_task.h"

#include "base/logging.h"
#include "im/adapters/session_adapter.h"

namespace imserver {

void UpdateSessionTask::run() {
  if (online_) {
    if (0 == SessionAdapter::Instance().AddSession(uid_, session_, 2)) {
      LOG_DEBUG("uid " << uid_ << " AddSession " << session_ << " ok.");
    } else {
      LOG_WARN("uid " << uid_ << " AddSession " << session_ << " err.");
    }
  } else {
    if (0 == SessionAdapter::Instance().RemoveSession(uid_, session_, 2)) {
      LOG_DEBUG("uid " << uid_ << " RemoveSession " << session_ << " ok.");
    } else {
      LOG_WARN("uid " << uid_ << " RemoveSession " << session_ << " err.");
    }
  }
}

}


